package money;

public class Money {
	static int money = 0;
	 private static synchronized void addMoney() {
	        for (int i = 0; i < 2000; i++) {
	            money += 100;
	            System.out.println("Total is " + money);
	        }
	 }
	 private static synchronized void takeMoney() {
	        for (int i = 0; i < 2000; i++) {
	            money -= 100;
	            System.out.println("Total is " + money);
	        }
	 }
	 public static void main(String[] args) {
	        Thread t1 = new Thread() {  public void run() {   addMoney();    }        };
	        Thread t2 = new Thread() {  public void run() { takeMoney();    }        };
	        t1.start();  t2.start();
	 }

}
